#!/bin/sh
# ccase_create_DO.sh
# Description:
#   script for creating a DO from a view-private file
# Usage:
#   ccase_create_DO.sh <source_path> <destination_dir>

# this is for execution with clearaudit
if [ $1 = "-touch" ]; then
    touch $2
    exit 0
fi

DEBUG=1
prg=`basename $0`

sourceFile=$1
destDir=$2
fileName=`basename $sourceFile`
destFile=$destDir/$fileName

mv $sourceFile $destFile
if [ $? != 0 ]; then
    test $DEBUG && echo  "Cannot move $sourceFile to $destFile"
    exit 1
fi

CLEARAUDIT_SHELL=$SHELL
export CLEARAUDIT_SHELL
clearaudit $0 -touch $destFile

if [ $? = 0 ]; then
    test $DEBUG && echo  "Created DO $destFile"
else
    test $DEBUG && echo  "Creation of DO faild. Cleaning up"
    mv $destFile $sourceFile
    exit 1
fi
